/* ********************************************************************************************
*  Alvin Baldemeca
*  Tetris Project
*  Course: TCSS 305 , Alan Fowler
*  Term: Spring 2012
*  UNIVERISTY OF WASHINGTON TACOMA
*
*
**********************************************************************************************/

package gui.actions;


import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;


import javax.swing.AbstractAction;
import javax.swing.Action;
import view.TetrisBoardPanel;
import view.TetrisGUI;






/**
 * The action to be attached to the ellipse tool in the Power Paint program.
 * @author Alvin Baldemeca
 * @version 5/17/2012
 */
@SuppressWarnings("serial")
public class EndGameAction extends AbstractAction
{
  /**
   * The initial delay (in milliseconds) for the move timer.
   */
  public static final int INITIAL_MOVE_DELAY = 1000;
  
  /**
   * The tetris board panel to stop the to return to its initial state.
   */
  private final TetrisBoardPanel my_panel;
  
  /**
   * The gui needed to return to its initial state.
   */
  private final TetrisGUI my_gui;

  /**
   * This action restarts the tetris board to an empty state.
   * @param the_panel the panel to paint the initial message to.
   * @param the_gui to perform the reset to initial conditions.
   */
  public EndGameAction(final TetrisBoardPanel the_panel, final TetrisGUI the_gui) 
  {
    super("End Game");
    putValue(Action.MNEMONIC_KEY, KeyEvent.VK_E);
    putValue(Action.SELECTED_KEY, true);
    my_panel = the_panel;
    my_gui = the_gui;  
  }

  @Override
  public void actionPerformed(final ActionEvent the_event) 
  {
    my_gui.restGUI();
    my_panel.setInitialState(true);
    my_panel.repaint();
    my_panel.setFocusable(false);
    my_gui.resetTimer();
  }
  

}
